package com.ems.controller;

import com.ems.entity.TUser;
import com.ems.entity.TUserRole;
import com.ems.service.TUserRoleService;
import com.ems.service.TUserService;
import com.ems.util.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ZZH
 * @since 2022-06-27
 */
@RestController
@RequestMapping("/t-user-role")
public class TUserRoleController {
    @Autowired
    private TUserRoleService tUserRoleService;

    //查找用户数据(单)
    @GetMapping("/findOne/{userId}")
    public ResultUtil get(@PathVariable Integer userId){
        if (tUserRoleService.findOne(userId)==null){
            return ResultUtil.fail("用户不存在");
        }else {
            return ResultUtil.success(tUserRoleService.findOne(userId));
        }
    }



    //查找用户数据(打印所有)
    @GetMapping("/findAll")
    public ResultUtil findAll() {
        if (tUserRoleService.findAll() == null) {
            return ResultUtil.fail("查找失败");
        } else {
            return ResultUtil.success(tUserRoleService.findAll());
        }
    }
}
